/**
 * 
 */
package com.monkeyboy.security.session;

import java.io.IOException;

import javax.servlet.ServletException;

import org.springframework.security.web.session.SessionInformationExpiredEvent;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;

/**
 * @Description
 *
 * @author Gavin<br>
 *         2019年8月29日
 */
public class MySessionExpireStrategy implements SessionInformationExpiredStrategy {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.security.web.session.SessionInformationExpiredStrategy#
	 * onExpiredSessionDetected(org.springframework.security.web.session.
	 * SessionInformationExpiredEvent)
	 */
	@Override
	public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
		// note：这儿需要根据不同的请求类型返回不用的数据或者页面，主要是ajax/html
		event.getResponse().setContentType("application/json;charset=UTF-8");
		event.getResponse().getWriter().write("你已在别处登录！");
	}

}
